﻿@model PagedList.IPagedList<SpyApp.Models.Message>
@using PagedList.Mvc;
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="page-header">
    <h3>@ViewBag.Title</h3>
</div>

@using (Html.BeginForm("Index", "Test1", FormMethod.Get))
{
    <p>
        Find by name: @Html.TextBox("SearchString", ViewBag.currentFilter as string)  
        <input type="submit" value="Search" />
    </p>
}

<table>
    <thead>
        <tr>
            <th>Type</th>
            <th>
                @Html.ActionLink("Number", "Index", new {sortOrder = ViewBag.NumberSortParm, currentFilter = ViewBag.CurrentFilter })
            </th>
            <th>
                @Html.ActionLink("Context", "Index", new {sortOrder = ViewBag.ContextParm, currentFilter = ViewBag.CurrentFilter})
            </th>
            <th>At</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>@item.Type</td>
                <td>@item.NumberSendReceive</td>
                <td>@item.UserMessage</td>
                <td>@item.SendDateTime</td>
            </tr>
        }
    </tbody>
    <tfoot>
        @*<tr>
            <td colspan="4">
               @for(var i=0;i<info.PageCount;i++)
                  {
                     if(i==info.CurrentPageIndex)
                     {
                        <span>@(i+1)</span>
                     }
                     else
                     {
                        <a href="#" data-pageindex="@i"
                           class="pager">@(i + 1)</a>
                     }
               }
            </td>
         </tr>*@

    </tfoot>
</table>

<br />
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount

@Html.PagedListPager(Model, page => Url.Action("Index", 
    new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))